﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace TfL
{
    //[Serializable]
    public class LineStatus
    {
        public LineStatus()
        {
            Line = new Line();
            Status  = new Status();
            StatusDetails = string.Empty;
            ID = string.Empty;
            BranchDisruptions = new BranchDisruption[] { };
        }
        [XmlArray("BranchDisruptions")]
        public BranchDisruption[] BranchDisruptions { get; set; }
        [XmlElement]
        public Line Line { get; set; }
        [XmlElement]
        public Status Status { get; set; }
        [XmlAttribute]
        public string StatusDetails { get;  set; }
        [XmlAttribute]
        public string ID { get; set; }

        public override string ToString()
        {
            string bd = string.Empty;
            if (BranchDisruptions != null)
                bd = BranchDisruptions.Aggregate("", (seed, disruption) => seed + "\t" + disruption.ToString() + "\n\r");
            return string.Format("{0} - {1} \n\r{2}",Line,StatusDetails,bd);
        }
    }
}
